import 'package:flutter/material.dart';

///**
///* @author hrongyong
///* @date   3/1/21
///* @email hrongyong@gmail.com
///* Description: 通用图表model 目前只有两个直方图 + 一个折线图（需要再加）
///*/
class GeneralChartModel {
  ///标题
  String name;

  ///第一个直方图
  double firstHistogram;

  ///第一个直方图描述
  String firstHistogramDescription;

  ///第一个直方图的颜色
  Color firstHistogramColor;

  ///第二个直方图
  double secondHistogram;

  ///第二个直方图描述
  String secondHistogramDescription;

  ///第二个直方图的颜色
  Color secondHistogramColor;

  ///第三个直方图
  double thirdHistogram;

  ///第三个直方图描述
  String thirdHistogramDescription;

  ///第三个直方图的颜色
  Color thirdHistogramColor;

  ///第一个折线
  double firstPolyline;

  ///第一个折线描述
  String firstPolylineDescription;

  ///第一个折线的颜色
  Color firstPolylineColor;

  ///第二个折线
  double secondPolyline;

  ///第一个折线描述
  String secondPolylineDescription;

  ///第一个折线的颜色
  Color secondPolylineColor;

  ///默认构造器(非空构造器)
  GeneralChartModel({
    @required this.name,
    this.firstHistogram = 0.0,
    this.firstHistogramDescription = "",
    this.secondHistogram = 0.0,
    this.secondHistogramDescription = "",
    this.firstPolyline = 0.0,
    this.firstPolylineDescription = "",
    this.secondPolyline = 0.0,
    this.secondPolylineDescription = "",
    this.thirdHistogram = 0.0,
    this.thirdHistogramDescription = "",
    this.firstHistogramColor,
    this.secondHistogramColor,
    this.thirdHistogramColor,
    this.firstPolylineColor,
    this.secondPolylineColor,
  }) {
    if (name == null) name = '';
    if (firstHistogram == null) firstHistogram = 0.0;
    if (secondHistogram == null) secondHistogram = 0.0;
    if (thirdHistogram == null) thirdHistogram = 0.0;
    if (firstPolyline == null) firstPolyline = 0.0;
  }

  ///直方非负构造器
  static GeneralChartModel histogramNonNegative({
    @required String name,
    double firstHistogram = 0.0,
    double secondHistogram = 0.0,
    double thirdHistogram = 0.0,
    double firstPolyline = 0.0,
    double secondPolyline = 0.0,
  }) {
    if (firstHistogram < 0.0) firstHistogram = 0.0;
    if (secondHistogram < 0.0) secondHistogram = 0.0;
    return GeneralChartModel(
      name: name,
      firstHistogram: firstHistogram,
      secondHistogram: secondHistogram,
      thirdHistogram: thirdHistogram,
      firstPolyline: firstPolyline,
      secondPolyline: secondPolyline,
    );
  }
}
